fix: LB Creation avoid 404 API errors due to non-needed patches#12835
fix: LB Creation avoid 404 API errors due to non-needed patches#12835ZhyliaievD wants to merge 1 commit intoapache:4.22from
Conversation
There was a problem hiding this comment.
Pull request overview
This PR optimizes NSX load balancer creation by avoiding unnecessary API PATCH calls when resources already exist and don't need updating. It fixes a bug where createAndAddNsxLbVirtualServer() was checking for an existing virtual server using the wrong name (the LB service name instead of the virtual server name), causing it to never detect existing virtual servers.
Changes:
- Skip monitor profile patching when the profile already exists in NSX, and skip server pool patching when the pool already has the same members
- Fix the virtual server existence check to use the correct virtual server name instead of the LB service name, so existing virtual servers are detected and not re-patched
- Add comprehensive unit tests covering all the new skip/patch scenarios
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
plugins/network-elements/nsx/src/main/java/org/apache/cloudstack/service/NsxApiClient.java |
Add existence checks for monitor profiles, server pools, and virtual servers to avoid unnecessary NSX API patch calls; fix virtual server lookup to use correct name |
plugins/network-elements/nsx/src/test/java/org/apache/cloudstack/service/NsxApiClientTest.java |
Add tests for monitor profile reuse, pool member comparison skip/patch logic, and virtual server existence detection |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## 4.22 #12835 +/- ##
============================================
+ Coverage 17.61% 17.99% +0.37%
- Complexity 15706 16557 +851
============================================
Files 5921 6022 +101
Lines 532392 541426 +9034
Branches 65109 66350 +1241
============================================
+ Hits 93788 97409 +3621
- Misses 428015 433043 +5028
- Partials 10589 10974 +385
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
9f079d8 to
4ea0f3d
Compare
|
@blueorangutan package |
|
@DaanHoogland a [SL] Jenkins job has been kicked to build packages. It will be bundled with no SystemVM templates. I'll keep you posted as I make progress. |
There was a problem hiding this comment.
Pull request overview
This PR avoids unnecessary NSX API patch calls during load balancer creation by checking if resources already exist before patching, preventing 404 errors.
Changes:
- Skip server pool patching when existing pool has identical members; skip virtual server patching when it already exists.
- Reuse existing LB active monitor profiles instead of re-patching them, fetching by ID directly rather than listing all profiles.
- Fix
createAndAddNsxLbVirtualServer()to look up the virtual server by its own name instead of the LB service name.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
NsxApiClient.java |
Added existence checks for pools, monitor profiles, and virtual servers before issuing patch calls; fixed virtual server lookup key. |
NsxApiClientTest.java |
Added tests covering skip/patch scenarios for server pools, monitor profiles, virtual servers, and error handling. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 17174 |
4ea0f3d to
94cabcd
Compare
|
@blueorangutan test |
1 similar comment
|
@blueorangutan test |
|
@sureshanaparti a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests |
|
[SF] Trillian test result (tid-15714)
|
|
@weizhouapache @winterhazel a kind reminder about this PR 😅 |
winterhazel
left a comment
There was a problem hiding this comment.
Code looks good to me. I just left some minor remarks.
@Pearl1594 @nvazquez could you have a look at this one too?
There was a problem hiding this comment.
Thanks for the improvement @ZhyliaievD! Code LGTM - some minor remarks raised by @winterhazel, could be great if addressed
94cabcd to
5785a43
Compare
Covered all comments, thanks for review |
|
@blueorangutan package |
|
@DaanHoogland a [SL] Jenkins job has been kicked to build packages. It will be bundled with no SystemVM templates. I'll keep you posted as I make progress. |
|
Packaging result [SF]: ✖️ el8 ✖️ el9 ✔️ debian ✖️ suse15. SL-JID 17419 |
|
@blueorangutan package |
|
@nvazquez a [SL] Jenkins job has been kicked to build packages. It will be bundled with no SystemVM templates. I'll keep you posted as I make progress. |
|
Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 17422 |
|
@blueorangutan test |
|
@nvazquez a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests |
|
[SF] Trillian test result (tid-15839)
|
|
@nvazquez @Pearl1594 @ZhyliaievD ccan you advise on testing? |
Tested on 4.22.0.0 base, see #12834 (comment) |
|
same for this one
does it then make sense to base ofo of 22 and merge on that? |
weizhouapache
left a comment
There was a problem hiding this comment.
code lgtm
better to fix into 4.22.1.0
cc @sureshanaparti @rajujith
@ZhyliaievD can re-target to 4.22? |
Fix existing lbVirtualServer search by lbVirtualServerName
5785a43 to
557d483
Compare
|
@sureshanaparti Done |
|
Thanks @ZhyliaievD @blueorangutan package |
|
@nvazquez a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress. |
|
Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 17508 |
|
@blueorangutan test |
|
@nvazquez a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests |
Description
Types of changes
Feature/Enhancement Scale or Bug Severity
Feature/Enhancement Scale
Screenshots (if appropriate):
How Has This Been Tested?
How did you try to break this feature and the system with this change?